<?php

App::import('Model','config.BaseConfig');
class DealConfig extends BaseConfig
{
	var $name = 'DealConfig';
	var $actsAs = array('Config.StartupConfig');
	var $validate = array(
			'paypal_account'=>array(
					'notEmpty'=>array(
							'rule'=>VALID_NOT_EMPTY,
							'message'=>'This field is required'
					),
					'validEmail'=>array(
							'rule'=>VALID_EMAIL,
							'message'=>'Please enter a valid email address'
					),
			),
			'sandbox'=>array(
					'rule'=>VALID_NOT_EMPTY,
					'message'=>'This field is required'
			),
			'currency'=>array(
					'rule'=>VALID_NOT_EMPTY,
					'message'=>'This field is required'
			),
			'currency_symbol'=>array(
					'rule'=>VALID_NOT_EMPTY,
					'message'=>'This field is required'
			),
			'tax'=>array(
					'validNumber'=>array(
							'rule' => 'numeric',
							'message' => "Invalid value",
							'required' => false,
							'allowEmpty' => true
					),
					'notLessThanZeroCheck'=>array(
							'rule' => array('comparison','>=',0),
							'message' => "Entered value should be greater than or equal to zero",
							'required' => false,
							'allowEmpty' => true
					)
			),
	);
				
	//var $cache = true;
	
	var $fieldProperties = array(
			'enable_deals'=>array(
					'label'=>'Enable Deals',
					'type'=>'checkbox',
					'group'=>'add',
					'tooltip'=>'Enable Deals'
			),
			'paypal_account'=>array(
					'group'=>array('add'),
					'label'=>'Paypal Email',
					'type'=>'text',
			),
			'sandbox'=>array(
					'group'=>array('add'),
					'label'=>'Enable Sandbox',
					'type'=>'select',
					'options'=>array()
			),
			'currency' => array(
					'type'=>"text",
					'class'=>'vsmall_input',
					'label'=>"Payment Currency (USD,GBP)",
					'group'=>array("add"),
					'default'=>"USD",
			),
			'currency_symbol' => array(
					'label'=>"Currency symbol  (\$, &pound;)",
					"type"=>"text",
					'class'=>'vsmall_input',
					'group'=>array("add"),
					'default'=>"\$"
			),
			'tax' => array(
					'label'=>"Tax(%) to be applied on Order",
					'type'=>"text",
					'class'=>'vsmall_input',
					'group'=>array("add")
			),
	);
							
	function initialize()
	{
		$afterText = __("Enter email of paypal account where amount should be received");
		$this->setFieldProperties('paypal_account',array('after'=>$afterText));
		
		$afterText = __("Only for testing purposes, enable sandbox. When sandbox is enabled, only mock transactions will be performed.");
		$options = array(0 => __("No"),1 => __("Yes"));
		$this->setFieldProperties('sandbox', array('options'=>$options,'after'=>$afterText));
		parent::initialize();
	}
}
?>